<script setup lang="ts">
import { IPackNifi } from 'src/inter';
import { ref,computed } from 'vue';
import {t} from "../../i18n/index"

const { cell, nifi } = defineProps<IPackNifi.CellProps>();
//
const mode = computed(() => nifi.graph.mode.value)
const sn = nifi.Select.selectCount;
const status = ref<IPackNifi.NIFI_CELL_STATUS>(cell.prop('status'))

// 复制 居中 刷新 列出队列 清空队列 编辑 查看 删除
const handleCopy = () => {nifi.Select.copy()}
const handleCenter = () => {nifi.graph.centerCell(cell)}
const handleRefresh = () => {nifi.cells.connections.refresh(cell)}
const handleView = () => {nifi.cells.connections.view(cell)}
const handleEdit = () => {nifi.cells.connections.edit(cell)}
const handleDelete = () => {nifi.cells.delCell(cell)}
//
const handleShowList = () => {}
const handleDelList = () => {}
</script>

<template>
    <!-- 多选菜单 -->
    <div v-if="sn > 1 && mode != 'prod'" class="w-fit h-fit">
        <div class="flex items-center icon-btn" @click="handleCopy"><i></i><span>{{t('cells-contextmenu-copy')}}</span></div>
    </div>
    <div v-else class="relative w-fit gap-x-20px max-h-240px flex flex-col flex-wrap">
        <div class="flex items-center icon-btn" @click="handleCenter"><i></i><span>{{t('cells-contextmenu-center')}}</span></div>
        <div class="flex items-center icon-btn" @click="handleRefresh"><i></i><span>{{t('cells-contextmenu-refresh')}}</span></div>
        <div class="h-1px bg-gray-200 m-y-4px"></div>

        <div v-if="mode == 'prod' || status == 'Running'" class="flex items-center icon-btn" @click="handleView"><i></i><span>{{t('cells-contextmenu-view')}}</span></div>
        <div v-if="mode == 'dev' && status != 'Running'" class="flex items-center icon-btn" @click="handleEdit"><i></i><span>{{t('cells-contextmenu-edit')}}</span></div>
        <div v-if="mode == 'dev' && status != 'Running'" class="flex items-center icon-btn" @click="handleDelete"><i></i><span>{{t('cells-contextmenu-delete')}}</span></div>
        <div class="h-1px bg-gray-200 m-y-4px"></div>
        <div class="flex items-center icon-btn" @click="handleShowList"><i></i><span>{{t('cells-contextmenu-list-quene')}}</span></div>
        <div v-if="mode == 'dev' && status != 'Running'" class="flex items-center icon-btn" @click="handleDelList"><i></i><span>{{t('cells-contextmenu-clear-quene')}}</span></div>
    </div>
</template>